package org.ceteca.explica.core.partners;

import java.io.Serializable;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.ceteca.explica.core.common.BaseVO;
import org.ceteca.explica.core.extTables.ExtTableOT;



/**
 * @author Juan C. Díaz (juancarlosdiaz@ceteca.net) <br>
 *         Copyright (c) 2009 Fundación Centro Tecnolóxico da Carne
 * 
 * <br>
 * <br>
 *         This program is free software: you can redistribute it and/or modify
 *         it under the terms of the GNU General Public License as published by
 *         the Free Software Foundation, either version 3 of the License, or (at
 *         your option) any later version. <br/>
 *         This program is distributed in the hope that it will be useful, but
 *         WITHOUT ANY WARRANTY 
 *         <br>without even the implied warranty of
 *         MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 *         General Public License for more details. <br/>
 *         You should have received a copy of the GNU General Public License
 *         along with this program. If not, see <http://www.gnu.org/licenses/>.
 * 
 */
public class PartnerGroupOT extends BaseVO implements Serializable {


	
	/**
	 * 
	 */
	private static final long serialVersionUID = -4857317200761269836L;
	private long idPartnerGroup;
	private String description;
	private Integer version= new Integer(0);
	private ExtTableOT extTable;
	
	

	public PartnerGroupOT() {
		super();
	}

	public long getIdPartnerGroup() {
		return idPartnerGroup;
	}

	public void setIdPartnerGroup(long idPartnerGroup) {
		this.idPartnerGroup = idPartnerGroup;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	
	
	
	/*
	public RateOT getRate() {
		return rate;
	}

	public void setRate(RateOT rate) {
		this.rate = rate;
	}
	*/
	
	@Override
	public boolean equals(Long id) {
		return id != null && this.idPartnerGroup == id.longValue();
	}
	

	@Override
	public String toString() {

		StringBuffer result = new StringBuffer();
		
	try{
			result.append("\n%%%%%%%%%%%% BEGIN PARTNER GROUP DETAIL %%%%%%%%%%%%%%");
			result.append("\nID: ");
			result.append(this.idPartnerGroup);
			result.append("\nDescription: ");
			result.append(this.description);
			result.append("\n%%%%%%%%%%%% END PARTNER GROUP  DETAIL %%%%%%%%%%%%%%%%");
		}
		catch (Exception ex) {
			System.out.println("Error formatting Partner Group!");
			ex.printStackTrace();
			return null;
		}
		
		return result.toString();

	}

	@Override
	public String getEntityId() {
	
		return InterfacePartners.EXPLICA_ENTITY_PARTNERGROUP_ID;
	}

	@Override
	public long getInternalId() {

		return this.idPartnerGroup;
	}

	@Override
	public String getInternalValue() {

		return this.description;
	}

	public Integer getVersion() {
		return version;
	}

	public void setVersion(Integer version) {
		this.version = version;
	}

	   @Override
	    public int hashCode() {
	        final HashCodeBuilder hcb = new HashCodeBuilder();
	        hcb.append(getDescription());
	        return hcb.toHashCode();
	    }

	    
	    
	    @Override
	    public boolean equals(Object obj) {
	        boolean isEquals = false;
	        try {
	            final PartnerGroupOT other = (PartnerGroupOT)obj;
	            final EqualsBuilder eqb = new EqualsBuilder();
	            eqb.append(getDescription(), other.getDescription());

	            isEquals = eqb.isEquals();

	        } catch (Exception e) {
	            isEquals = false;
	        }

	        return isEquals;
	    }
	    
	    

		public ExtTableOT getExtTable() {
			return extTable;
		}

		public void setExtTable(ExtTableOT extTable) {
			this.extTable = extTable;
		}

	
	    
	
	    
	    

}
